package com.ruoyi.project.system.material.img.service.impl;

import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.common.utils.uniquekey.IdGererateFactory;
import com.ruoyi.project.system.material.img.domain.MaterialImg;
import com.ruoyi.project.system.material.img.mapper.MaterialImgMapper;
import com.ruoyi.project.system.material.img.service.IMaterialImgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 素材中心图片Service业务层处理
 * 
 * @author LCL
 * @date 2021-01-21
 */
@Service
public class MaterialImgServiceImpl implements IMaterialImgService
{
    @Autowired
    private MaterialImgMapper materialImgMapper;
    @Resource
    private IdGererateFactory idGererateFactory;

    /**
     * 查询素材中心图片
     * 
     * @param id 素材中心图片ID
     * @return 素材中心图片
     */
    @Override
    public MaterialImg selectMaterialImgById(String id)
    {
        return materialImgMapper.selectMaterialImgById(id);
    }

    /**
     * 查询素材中心图片列表
     * 
     * @param materialImg 素材中心图片
     * @return 素材中心图片
     */
    @Override
    public List<MaterialImg> selectMaterialImgList(MaterialImg materialImg)
    {
        return materialImgMapper.selectMaterialImgList(materialImg);
    }

    /**
     * 新增素材中心图片
     * 
     * @param materialImg 素材中心图片
     * @return 结果
     */
    @Override
    public int insertMaterialImg(MaterialImg materialImg)
    {
        materialImg.setId(this.idGererateFactory.nextStringId());
        return materialImgMapper.insertMaterialImg(materialImg);
    }

    /**
     * 修改素材中心图片
     * 
     * @param materialImg 素材中心图片
     * @return 结果
     */
    @Override
    public int updateMaterialImg(MaterialImg materialImg)
    {
        return materialImgMapper.updateMaterialImg(materialImg);
    }

    /**
     * 删除素材中心图片对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteMaterialImgByIds(String ids)
    {
        return materialImgMapper.deleteMaterialImgByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除素材中心图片信息
     * 
     * @param id 素材中心图片ID
     * @return 结果
     */
    @Override
    public int deleteMaterialImgById(String id)
    {
        return materialImgMapper.deleteMaterialImgById(id);
    }

    @Override
    public List<MaterialImg> findListByMaterialIdAndType(String materialId, Integer type) {
        return materialImgMapper.findListByMaterialIdAndType(materialId,type);
    }

    @Override
    public int deleteByMaterialId(String materialId) {
        return materialImgMapper.deleteByMaterialId(materialId);
    }
}
